package day240607.thread;

public class ThreadDeadlockExample {
    private static Object object=new Object();
    private static Object object1=new Object();
    public static void main(String[] args) {
       Thread thread1= new Thread(() -> {
 synchronized (object){
     try {
         Thread.sleep(100);
         System.out.println(1);
     } catch (InterruptedException e) {
         throw new RuntimeException(e);
     }
     synchronized (object1){
         System.out.println(2);
     }
 }
        });
       Thread thread2= new Thread(() -> {
           synchronized (object1){
               try {
                   Thread.sleep(100);
                   System.out.println(2);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
               synchronized (object){
                   System.out.println(1);
               }
           }
       });
       thread1.start();
       thread2.start();
    }
}
